home *** CD-ROM | disk | FTP | other *** search
/ AI Game Programming Wisdom / AIGameProgrammingWisdom.iso / SourceCode / 03 Pathfinding with Astar / 04 Higgins / Listing4.cpp < prev    next >
Encoding:
Text File  |  2001-12-09  |  968 b   |  29 lines

  1. /* Copyright (C) Dan Higgins, 2001. 
  2.  * All rights reserved worldwide.
  3.  *
  4.  * This software is provided "as is" without express or implied
  5.  * warranties. You may freely copy and compile this source into
  6.  * applications you distribute provided that the copyright text
  7.  * below is included in the resulting source code, for example:
  8.  * "Portions Copyright (C) Dan Higgins, 2001"
  9.  */
  10.  
  11. AStarStorage::AddNodeToClosedList(AStarNode* inNode)
  12. {
  13.     // Generate a hash code.
  14.     long theHash = this->Hash(inNode->mX, inNode->mY);
  15.  
  16.     // Drop it into that list, and setup list pointers.
  17.     if(this->mClosedLists[theHash] != NULL)
  18.         this->mClosedLists[theHash]->mListParent = inNode;
  19.  
  20.     // the current bucket head is now our next node.
  21.     inNode->mNext = this->mClosedLists[theHash];
  22.  
  23.     // This is now the head of this bucket's list.
  24.     this->mClosedLists[theHash] = inNode;
  25.  
  26.     // set the closed node flag
  27.     this->SetClosedFlag(this->GetFlag(inNode->mX, inNode->mY));
  28. }
  29.